﻿using System;

namespace Zive.Color {

    public class HslColorSpaceChannelInfoCollection: ColorSpaceChannelInfoCollection {

        //
        // Interface
        //

        internal HslColorSpaceChannelInfoCollection( ) { }

        public override ColorSpaceChannelInfo this[ int index ] {
            get { return _channelInfoCollection[ index ]; }
        }

        //
        // Implementation
        //

        private class HueHslColorSpaceChannelInfo: ColorSpaceChannelInfo<HslChannels> {

            public override HslChannels Value {
                get { return HslChannels.H; }
            }

            public override int IntegerValue {
                get { return (int) HslChannels.H; }
            }

            public override string Name {
                get { return "H"; }
            }

            public override double MinimumValue {
                get { return 0d; }
            }

            public override double MaximumValue {
                get { return 360d; }
            }

            public override double Range {
                get { return 360d; }
            }

        }

        private class OtherHslColorSpaceChannelInfo: ColorSpaceChannelInfo<HslChannels> {

            public OtherHslColorSpaceChannelInfo( HslChannels channel, string name ) {
                _channel = channel;
                _name = name;
            }

            public override HslChannels Value {
                get { return _channel; }
            }

            public override int IntegerValue {
                get { return (int) _channel; }
            }

            public override string Name {
                get { return _name; }
            }

            public override double MinimumValue {
                get { return 0d; }
            }

            public override double MaximumValue {
                get { return 100d; }
            }

            public override double Range {
                get { return 100d; }
            }

            private readonly HslChannels _channel;
            private readonly string _name;

        }

        private static readonly ColorSpaceChannelInfo<HslChannels>[ ] _channelInfoCollection = {
            new HueHslColorSpaceChannelInfo( ),
            new OtherHslColorSpaceChannelInfo( HslChannels.S, "S" ),
            new OtherHslColorSpaceChannelInfo( HslChannels.L, "L" ),
        };

    }

    public class HslColorSpaceInfo: ColorSpaceInfo<HslColor> {

        //
        // Interface
        //

        public override string Name {
            get { return "W3C CSS3 HSL"; }
        }

        public override string Label {
            get { return "HSL"; }
        }

        public override int NumberOfChannels {
            get { return 3; }
        }

        public override Type ColorType {
            get { return typeof( HslColor ); }
        }

        public override Type ChannelsType {
            get { return typeof( HslChannels ); }
        }

        public override Type ConverterType {
            get { return typeof( HslColorConverter ); }
        }

        public override ColorSpaceChannelInfoCollection Channels {
            get { return _channelInfoCollection; }
        }

        public override HslColor CreateColorInstance( ) {
            return new HslColor( );
        }

        //
        // Implementation
        //

        private static readonly ColorSpaceChannelInfoCollection _channelInfoCollection = new HslColorSpaceChannelInfoCollection( );

    }

}
